Hello.
const string fullNameSpecIndex = "\Project\Spec_Index"
string buildStringArrayOfAttributeType(AttrType at)[] {
int i
string result[at.size]
for i in 0:at.size - 1 do {
result[i] = at.strings[i]
}
return result
}
Module modSpecIndex = read(fullNameSpecIndex, false)
AttrType typeSupplier = find(modSpecIndex, "t_Supplier")
string arrSuppliers[] = buildStringArrayOfAttributeType(typeSupplier)
MichaelGeorg - Thu Oct 11 08:52:20 EDT 2012 |
Re: Cause of: Incorrect context for function call
Hi, void buildStringArrayOfAttributeType(AttrType at, string &szArray[])
|
Re: Cause of: Incorrect context for function call adevicq - Thu Oct 11 09:09:55 EDT 2012
Hi, void buildStringArrayOfAttributeType(AttrType at, string &szArray[])
Hi again,
void x(string &s[]) {
int i
for (i=0; i < sizeof(s); ++i)
s[i] = "elem " i ""
}
string w[4]
x(w)
for (i = 0; i < sizeof(w); ++i) {
print "elem " i "\n"
}
|
Re: Cause of: Incorrect context for function call adevicq - Thu Oct 11 09:30:15 EDT 2012
Hi again,
void x(string &s[]) {
int i
for (i=0; i < sizeof(s); ++i)
s[i] = "elem " i ""
}
string w[4]
x(w)
for (i = 0; i < sizeof(w); ++i) {
print "elem " i "\n"
}
you have to indicate the array size in the function daclaration. |
Re: Cause of: Incorrect context for function call adevicq - Thu Oct 11 09:34:26 EDT 2012
@adevicq: Thanks for your help. string x()[]
successfully before I did build it into my code - but now I can't reproduce that :-( |
Re: Cause of: Incorrect context for function call MichaelGeorg - Thu Oct 11 09:55:56 EDT 2012
@adevicq: Thanks for your help. string x()[]
successfully before I did build it into my code - but now I can't reproduce that :-( Alain |
Re: Cause of: Incorrect context for function call For this particular problem, I do this:
-Louie |
Re: Cause of: Incorrect context for function call https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14301349� https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14472558#14472558 https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14472624� https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14777803� Maybe that helps, regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Cause of: Incorrect context for function call @Louie: First counting the enum entries is just the way I've gone now. (Even so I still don't really like that way.) @Mathias: Thanks for all the additional links. My conclusion form them is you can't or at least shouldn't use arrays as return values, like Louie and Alain pointed out above. :-) |
Re: Cause of: Incorrect context for function call MichaelGeorg - Tue Oct 16 09:18:32 EDT 2012
Well the error message "invalid context for function call" tells you, that you did the function call alright, but you put it in an assignment that DXL does not know how to evaluate. The only way of assigning arrays during declaration in DXL is:
int ar[] = {1,2,3,4,5}
Now the parser finds an array declaration that matches the return value of your function, but it does not support assignment. A similar thing happens, when you try to do this:
int func() { return 3 }
int &ref = func()
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|